export default {
    actons:[],
    timeId:0,
    run(){
        let _timeId = localStorage.getItem("_timeId");
        clearInterval(_timeId);
        var actions = this.actons;
        this.timeId = setInterval(()=>{
            for (let i in actions) {
                let item = actions[i];
                item.action();
            }
        },1000);
        localStorage.setItem("_timeId",this.timeId);
        this.push("timer_init",()=>{
            window.injectTime?window.injectTime():null;
        });
    },
    kill(){
        clearInterval(this.timeId);
    },
    push(k,cb){ 
        let action = {
            "key":k,
            "action":cb
        };
        for (let i in this.actons) {
            if( this.actons[i].key  === k){
                this.actons[i] = action;
                return;
            }
        }
        this.actons.push(action); 
    }
}